// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class Control extends cc.Component {

    static inst : Control = null;

    //@property({displayName:"标靶转速"})
    targetRotation: number = 3;

    //@property({displayName:"标靶转向"})
    //targetDir: number = 0;

    // LIFE-CYCLE CALLBACKS:

    onLoad () {

        Control.inst = this;
    }

    start () {

    }

    // 顺时针匀速
    fixedSpeed() {

        this.targetRotation = 3;
    } 

    // 顺时针变速
    changeSpeed() {

        let speed = 1 + Math.random() * 6;

        //this.targetRotation = Math.abs(speed);
        this.targetRotation = speed;
    }

    // 双向变速
    changeDirAndSpeed() {

        let dir = Math.random() > 0.5 ? 1 : -1;
        let speed = 1 + Math.random() * 6;

        this.targetRotation = dir * speed;
    }

    // update (dt) {}
}
